export default function () {
  function fullScreen() {
    var explorer = window.navigator.userAgent.toLowerCase();
    if (explorer.indexOf("chrome") > 0) {
      //webkit
      if (
        document.body.scrollHeight === window.screen.height &&
        document.body.scrollWidth === window.screen.width
      ) {
        exitFullscreen.call(this);
      } else {
        enterFullscreen.call(this);
      }
    } else {
      //IE 9+  fireFox
      if (
        window.outerHeight === window.screen.height &&
        window.outerWidth === window.screen.width
      ) {
        exitFullscreen.call(this);
      } else {
        enterFullscreen.call(this);
      }
    }
    function enterFullscreen() {
      var docElm = document.documentElement;
      //W3C
      if (docElm.requestFullscreen) {
        docElm.requestFullscreen();
      }
      //FireFox
      else if (docElm.mozRequestFullScreen) {
        docElm.mozRequestFullScreen();
      }
      //Chrome等
      else if (docElm.webkitRequestFullScreen) {
        docElm.webkitRequestFullScreen();
      }
      //IE11
      else if (docElm.msRequestFullscreen) {
        docElm.msRequestFullscreen();
      }
    }
    function exitFullscreen() {
      //W3C
      if (document.exitFullscreen) {
        document.exitFullscreen();
      }
      //FireFox
      else if (document.mozCancelFullScreen) {
        document.mozCancelFullScreen();
      }
      //Chrome等
      else if (document.webkitCancelFullScreen) {
        document.webkitCancelFullScreen();
      }
      //IE11
      else if (document.msExitFullscreen) {
        document.msExitFullscreen();
      }
    }
  }
  return {
    fullScreen
  }
}